//
//  YBApiManager.h
//  YanzhouCloud
//
//  Created by Cocoa on 2019/7/2.
//  Copyright © 2019 yibai. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YBNetworking.h"
#import "NSError+NetworkErrorCheckout.h"



//  正式
//#define APIHost @"http://183.131.85.100:8080/api/"
//#define Socket_ip @"ws://183.131.85.100:7272"
//  测试
#define APIHost @"http://tx.gouwanmei.wang/api/"
#define Socket_ip @"ws://117.50.41.216:7272"


#define ImageHost  @"http://pw7tzwpat.bkt.clouddn.com"



static NSString *hostServer = @"host";
#define NetworkErrorCode_TokenInvalid (-1)  //  token失效
//#define NetworkErrorCode_TokenRelogin 704  //  其他设备登录



/**
 网络请求库
 */
@interface YBApiManager : NSObject

@property (nonatomic, strong, readonly) YBNetworking *rest;
@property (nonatomic, copy) NSString *ydd_aesKey;
@property (nonatomic, copy) NSString *ydd_aesIV;

+ (instancetype)shareManager;
- (instancetype)initWithServerURL:(NSString *)urlStr;

- (RACSignal *)p_requestRefreshToken;
- (RACSignal *)p_requestAccessToken;


- (RACSignal *)sendGetRequest:(NSString *)path param:(NSDictionary *)param;
- (RACSignal *)sendPostRequest:(NSString *)path param:(NSDictionary *)param;
- (RACSignal *)sendDeleteRequest:(NSString *)path param:(NSDictionary *)param;
- (RACSignal *)sendPutRequest:(NSString *)path param:(NSDictionary *)param;
- (RACSignal *)downloadTask:(NSString *)url;
- (RACSignal *)downloadTask:(NSString *)url filePath:(NSString *)filePath;
///  可以集中处理业务， 比如说token失效等、此处需要登录等
- (RACSignal *)sendRequest:(NSString *)method path:(NSString *)path param:(NSDictionary *)param;


@end

